python datetime remove timezone

54

python datetime remove timezone -

# dt_tz is a datetime.datetime object
dt = dt_tz.replace(tzinfo=None)

remove timezone from a datetime object? -

>>> import datetime
>>> import pytz
>>> dt = datetime.datetime.now()
>>> dt
datetime.datetime(2012, 6, 8, 9, 27, 32, 601000)
>>> dt_tz = pytz.utc.localize(dt)
>>> dt_tz
datetime.datetime(2012, 6, 8, 9, 27, 32, 601000, tzinfo=<UTC>)

Comments

Submit
0 Comments